package com.excilys.converter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.excilys.dto.UserDTO;
import com.excilys.model.User;

/**
 * Converter that allows to switch from the original User model to the UserDTO model
 * 
 * @author excilys dev: GF
 * 
 */

@Component
public class UserToUserDTOConverter {

	@Autowired
	private AccountToAccountDTOConverter accountConverter;

	public UserDTO convert(User user) {

		UserDTO userDTO = new UserDTO();

		userDTO.setUserDTOLogin(user.getUserLogin());
		userDTO.setUserDTOFirstName(user.getUserFirstName());
		userDTO.setUserDTOLastName(user.getUserLastName());
		userDTO.setUserDTOListAccountDTO(accountConverter.convertAccountList(user.getUserListAccounts()));

		return userDTO;
	}

}
